function jsonpProxy(
    url,
    params,
    callbackParam,
    timeout,
    successCallback,
    errorCallback
) {
    const script = document.createElement('script');
    // 设置请求参数
    const query = new URLSearchParams();
    for (const key in params) {
        if (Object.hasOwnProperty.call(params, key)) {
            query.append(key, params[key]);
        }
    }
    query.append(callbackParam, 'jsonpCallback');
    // 设置请求URL
    script.src = url + '?' + query.toString();
    // 创建回调函数
    window.jsonpCallback = function (data) {
        document.head.removeChild(script);
        successCallback(data);
        window.jsonpCallback = undefined;
    };
    document.head.appendChild(script);
    // 设置超时处理
    const timeoutId = setTimeout(function () {
        document.head.removeChild(script);
        errorCallback(new Error('请求超时'));
        window.jsonpCallback = undefined;
    }, timeout);
}
export { jsonpProxy };
